package lambda;

import java.util.Objects;

public class Test {
    public static void main(String[] args) {
//        searchRange()
        String s="helllo";
        s=new String("hello");
        System.out.println(Objects.toString(s));
    }


    public static int[] searchRange(int[] nums, int target) {
        int left=0,right=nums.length-1;
        int mid=(left+right)>>1;
        int l=getLeft(nums,target,left,mid);
        int r=getRight(nums,target,mid,right);
        if(l!=-1||r!=-1){
//            l==-1?return new int[]{r,r};:return new int[]{l,l};
             mid = 1==1?1:2;
        }
        return new int[]{l,r};

    }

    public static int  getLeft(int[]nums,int target,int left,int right){
        while(left<=right){
            int mid=(left+right)>>1;
            if(nums[mid]>target){
                right=mid-1;
            }else if(nums[mid]<target){
                left=mid+1;
            }else{
                return mid;
            }
        }
        //数组左半边没找到target
        return -1;
    }

    public static int getRight(int[]nums,int target,int left,int right){
        while(left<=right){
            int mid=(left+right)>>1;
            if(nums[mid]>target){
                right=mid-1;
            }else if(nums[mid]<target){
                left=mid+1;
            }else{
                return mid;
            }
        }
        //数组右半边没找到target
        return -1;
    }
}
